<link rel="stylesheet" type="text/css" href="../style/style.css">
<?
include("../lib/config.php");
$nik	= $HTTP_GET_VARS['nik'];
// get karyawan
$skar = mssql_query("SELECT NIK,Nama FROM Karyawan WHERE NIK='$nik'",$conn);
$rkar = mssql_fetch_array($skar);
?>
<table align="center" width="100%">
 <tr>
  <td colspan="2" align="center"><b>DAFTAR PLAFON PENGOBATAN</b></td>
 </tr>
 <tr>
  <td width="100">NIK:</td>
  <td><?=$rkar[NIK]?></td>
 </tr>
 <tr>
  <td>Nama:</td>
  <td><?=$rkar[Nama]?></td>
 </tr>
</table><br>
<hr noshade size="-2">
<table align="center" border="0" width="100%">
 <tr class="headlist">
  <td rowspan="2">No.</td>
  <td rowspan="2">Periode</td>
  <td colspan="3">Pengobatan/Rawat Jalan</td>
  <td colspan="3">Kaca Mata</td>
  <td colspan="3">Rawat Inap</td>
 </tr>
 <tr class="headlist">
  <td>Plafon</td>
  <td>Terpakai</td>
  <td>Sisa</td>
  <td>Plafon</td>
  <td>Terpakai</td>
  <td>Sisa</td>
  <td>Plafon</td>
  <td>Terpakai</td>
  <td>Sisa</td>
 </tr>
<?
$sql = mssql_query("SELECT ROW_NUMBER() OVER(ORDER BY NIK)AS No, * FROM MedicalSetupAwal WHERE NIK='$nik'",$conn);
while($row = mssql_fetch_array($sql)){
	echo"
	 <tr class='contentlist'>
	  <td>$row[No]</td>
	  <td>$row[Periode]</td>
	  <td align=right>Rp. ".number_format($row[PlafonRawatJalan])."</td>
	  <td align=right>Rp. ";
	// get 
	$sRJ = mssql_query("SELECT SUM(jml_disetujui) tot_setuju FROM MedicalRestitusiDetail WHERE Periode='$row[Periode]' AND NIK='$row[NIK]' AND mata_anggaran IN ('811101','811103','811105','811199') AND status='A'");
	$rRJ = mssql_fetch_array($sRJ);
	echo number_format($rRJ['tot_setuju']);
	echo"</td><td align=right bgcolor='#DEFEFE'>Rp. ";
	// sisa rawat jalan
	echo number_format($row[PlafonRawatJalan]-$rRJ['tot_setuju']);
	echo"
	  </td>
	  <td align=right>Rp. ".number_format($row[PlafonKacaMata])."</td>
	  <td align=right>Rp. ";
	// get jumlah kacamata yang disetujui
	$sKC = mssql_query("SELECT SUM(jml_disetujui) tot_setuju FROM MedicalRestitusiDetail WHERE Periode='$row[Periode]' AND NIK='$row[NIK]' AND mata_anggaran IN ('811104') AND status='A'");
	$rKC = mssql_fetch_array($sKC);
	echo number_format($rKC['tot_setuju']);
	echo"</td><td align=right bgcolor='#DEFEFE'>Rp. ";
	// sisa kaca mata
	echo number_format($row[PlafonKacaMata]-$rKC['tot_setuju']);
	echo"</td>";
	echo"<td align=right>Rp. ".number_format($row[PlafonRawatInap])."</td><td align=right>Rp. ";
	// get jumlah rawat inap yang disetujui
	$sRI = mssql_query("SELECT SUM(jml_disetujui) tot_setuju FROM MedicalRestitusiDetail WHERE Periode='$row[Periode]' AND NIK='$row[NIK]' AND mata_anggaran IN ('811102','811106') AND status='A'");
	$rRI = mssql_fetch_array($sRI);
	echo number_format($rRI['tot_setuju']);
	echo"</td><td align=right bgcolor='#DEFEFE'>Rp. ";
	// sisa rawat inap
	echo number_format($row[PlafonRawatInap]-$rRI['tot_setuju']);
	echo"</td>";
	echo"</tr>
	";
}
?>
</table>
<br>
<center>
<input type="button" value="Tutup" class="button" onClick="Javascript:window.close();">
</center>